package com.ht.config.minio;


import com.ht.config.minio.properties.SshProperties;
import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author hejialun
 * @ClassName MinioConfig
 * @description: TODO（minio配置文件）
 * @Date: 2024/6/5 9:51
 */
@Configuration
@Data
public class MinioConfig {
    @Value("${minio.url}")
    private String minioUrl;

    @Value("${minio.access}")
    private String accessKey;

    @Value("${minio.secret}")
    private String secretKey;

    @Value("${minio.bucket}")
    private String bucketName;

    @Value("${minio.store-path}")
    private String storePath;

    @Resource
    private SshProperties SshProperties;

    @Value("${minio.to-pdf-command}")
    private String toPdfCommand;

    /**
     * 获取转图片完整命令
     * @param filePath
     * @return
     */
    public String toPdfCommandInit(String filePath){
        return this.toPdfCommand
                .replace("$[sourceFile]",storePath+bucketName+"/"+filePath)
                .replace("$[targetPath]",storePath+bucketName+"/");
    }

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(minioUrl)
                .credentials(accessKey, secretKey)
                .build();
    }




}
